<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\BaseController;
use App\Models\Member;
use Dingo\Api\Http\Request;

class MemberController extends BaseController
{
    public $model = Member::class;

    public function store(Request $request) {
        $input = $request->input();
        $info = Member::create($input);
        return $this->success(['id' => $info->id]);
    }

    public function index(Request $request) {

        $real_name = $request->input('real_name');
        $search = ['phone' => '', 'start_at' => '', 'end_at' => ''];
        $input = $request->input();
        $list = Member::apply($search, $input)->when($real_name, function ($q)use($real_name) {
            $q->where('real_name', 'like', '%'. $real_name . '%');
        })->paginate(per_page());
        return $this->paginate($list);
    }

}

